import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 石方旭
 * Date: 2022-10-17
 * Time: 21:50
 */
@WebServlet("/redirectServlet")
public class redirectServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //302重定向   跳转到页面www.baidu.com
        //设置302重定向状态码
//        resp.setStatus(302);
//        //跳转到页面www.baidu.com
//        resp.setHeader("Location","https://www.baidu.com");
        resp.sendRedirect("https://www.baidu.com");
    }
}
